<?php
 $title = 'Products';
 $this->headTitle($title);
 ?>
 
 <script>
   function myFunction() {   
	    if (confirm("Are You Sure?") == true) {  
	    	//document.location = this.href;  
	    	//document.form.submit(); 
	    	window.location = "<?php echo $this->url('estore',
	             array('action'=>'delete', 'id' => $product->id));?>"
	    } else {  
	    	return false;
	    }
   }
</script>
	    	
 <h3><?php echo $this->escapeHtml($title);?></h3>
 <p>
     <a href="<?php echo $this->url('estore', array('action'=>'add'));?>" class="btn btn-default btn-lg">Add new product</a>  
 </p>

 <div class="table">
 <table>
 <tr>
     <th>Name</th>
     <th>Description</th>
     <th>Cost</th> 
     <th>&nbsp;</th>
 </tr>
 <?php foreach ($paginator as $product) : ?>
 <tr>
     <td><?php echo $this->escapeHtml($product->name);?></td>
     <td><?php echo $this->escapeHtml($product->desc);?></td>
     
     <td>
         <a href="<?php echo $this->url('estore',
             array('action'=>'productDetail', 'id' => $product->id));?>">View product</a>
             
         <a href="<?php echo $this->url('estore',
             array('action'=>'delete', 'id' => $product->id));?>">Delete</a>
         <a href="#" onclick="myFunction()">Delete js</a>
             
     </td>
 </tr>
 <?php endforeach; ?>
 </table>
 </div>
 
 <div class="pagination" >
 <?php
  // add at the end of the file after the table
  echo $this->paginationControl(
     // the paginator object
     $this->paginator,
     // the scrolling style
     'sliding',
     // the partial to use to render the control
     array('partial/paginator.phtml', 'Estore'),
     // the route to link to when a user clicks a control link
     array(
         'route' => 'estore'
     )
 );
 ?>
 </div>
 

